<template>
	<view>
		<image class="pbtp" :src="list1.image_text" mode=""></image>
		<view class="" style="padding: 1rpx 30rpx 30rpx;">
			<view class="margin_top radius ffffff flexbetween mainpadding" v-for="item in list.data" :key="item.id" @click="tzspxq(item.id,item.goods_attr)">
				<image class="sptp" :src="item.image_text" mode=""></image>
				<view class="" style="width: 71%;">
					<view class="titletext zhonghei fonweight xiankuan1">{{item.title}}</view>
					<view class="flexbetween margin_top">
						<view class="smalltext xiaohong fonweight">¥
							<text class="sishi xiaohong fonweight">{{item.goodsprice.pt_price}}</text>
						</view>
						<view class="xhtbn flexcenter">立即拼单</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				page: 1,
				limit: 12,
				list: {
					data: []
				},
				list1:{}
			}
		},
		onLoad() {
			this.init()
			this.getbanner()
		},
		methods: {
			getbanner() { //获取轮播图
				httpRequest.request('/api/index/getAdvertiseList', 'POST', {
					advertise_position_id: 3,
					is_more: 2
				}).then(res => {
					this.list1 = res.data
				}).catch(err => {})
			},
			init(isPage, page) {
				let _this = this
				httpRequest.request('/api/goodscl/goodsList', 'GET', {
					page: page || 1,
					limit: _this.limit,
					goods_attr:2,
				}).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			// 跳转拼单详情
			tzspxq(id,attr) {
				uni.navigateTo({
					url: '/pages_lianmengsc/shangpxq?id='+id+"&attr="+attr
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.xhtbn {
		width: 140rpx;
		height: 55rpx;
		background-color: #FF9341;
		border-radius: 120rpx;
		font-size: 24rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		color: #FFFFFF;
	}

	.sptp {
		width: 160rpx;
		height: 160rpx;
		border-radius: 14rpx 14rpx 14rpx 14rpx;
	}

	.pbtp {
		width: 100%;
		height: 145rpx;
	}
</style>